using Perfect.Marshal;
using System.Xml;

namespace editor
{
namespace cfg.jewelry
{
[System.Serializable]
public  class Jewelry :   cfg.EditorReadWriter 
 {

    public int id ;
     public string name  = "";
     public cfg.jewelry.EJewelryType jewelryType ;
     public string displayJewelryType  = "";
     public string icon  = "";
     public cfg.jewelry.EQualityColor quality ;
     public int wearCondition ;
     public string introduction  = "";
     public int maxPile ;
     public int durable ;
     public System.Collections.Generic.List<cfg.fight.AttrAreaMinMax> basicAttrArea  = new System.Collections.Generic.List<cfg.fight.AttrAreaMinMax>();
     public int quenchingAttrNum ;
     public System.Collections.Generic.Dictionary<int,int> affixNum  = new System.Collections.Generic.Dictionary<int,int>();
     public cfg.condition.MultiCondition transAffixCost  = new cfg.condition.MultiCondition();
     


    public const int TYPE_ID = 1720469500;

    public override int GetTypeId() {
        return TYPE_ID;
    }


    public override void MarshalCompatible(Perfect.Marshal.Octets os) {
        os.WriteSize(14);
        os.WriteSize(Tag.INT | (1 << Tag.TAG_SHIFT));  os.WriteInt(id);  
         os.WriteSize(Tag.STRING | (2 << Tag.TAG_SHIFT));  os.WriteString(name);  
         os.WriteSize(Tag.INT | (3 << Tag.TAG_SHIFT));  os.WriteInt((int)jewelryType);  
         os.WriteSize(Tag.STRING | (4 << Tag.TAG_SHIFT));  os.WriteString(displayJewelryType);  
         os.WriteSize(Tag.STRING | (5 << Tag.TAG_SHIFT));  os.WriteString(icon);  
         os.WriteSize(Tag.INT | (6 << Tag.TAG_SHIFT));  os.WriteInt((int)quality);  
         os.WriteSize(Tag.INT | (7 << Tag.TAG_SHIFT));  os.WriteInt(wearCondition);  
         os.WriteSize(Tag.STRING | (8 << Tag.TAG_SHIFT));  os.WriteString(introduction);  
         os.WriteSize(Tag.INT | (9 << Tag.TAG_SHIFT));  os.WriteInt(maxPile);  
         os.WriteSize(Tag.INT | (10 << Tag.TAG_SHIFT));  os.WriteInt(durable);  
         os.WriteSize(Tag.LIST | (11 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_cfg_fight_AttrAreaMinMax(basicAttrArea,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.INT | (12 << Tag.TAG_SHIFT));  os.WriteInt(quenchingAttrNum);  
         os.WriteSize(Tag.MAP | (13 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_map_int_int(affixNum,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.BEAN | (14 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_cfg_condition_MultiCondition(transAffixCost,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         
    }

    public override void UnmarshalCompatible(Perfect.Marshal.Octets os) {
        for (int _var_num_ = os.ReadSize(); _var_num_-- > 0; ) {
            int _id_ = os.ReadSize();
            switch (_id_)
            {
            case (Tag.INT | (1 << Tag.TAG_SHIFT)):   id = os.ReadInt(); break;  
             case (Tag.STRING | (2 << Tag.TAG_SHIFT)):   name = os.ReadString(); break;  
             case (Tag.INT | (3 << Tag.TAG_SHIFT)):   jewelryType = (cfg.jewelry.EJewelryType)(os.ReadInt()); break;  
             case (Tag.STRING | (4 << Tag.TAG_SHIFT)):   displayJewelryType = os.ReadString(); break;  
             case (Tag.STRING | (5 << Tag.TAG_SHIFT)):   icon = os.ReadString(); break;  
             case (Tag.INT | (6 << Tag.TAG_SHIFT)):   quality = (cfg.jewelry.EQualityColor)(os.ReadInt()); break;  
             case (Tag.INT | (7 << Tag.TAG_SHIFT)):   wearCondition = os.ReadInt(); break;  
             case (Tag.STRING | (8 << Tag.TAG_SHIFT)):   introduction = os.ReadString(); break;  
             case (Tag.INT | (9 << Tag.TAG_SHIFT)):   maxPile = os.ReadInt(); break;  
             case (Tag.INT | (10 << Tag.TAG_SHIFT)):   durable = os.ReadInt(); break;  
             case (Tag.LIST | (11 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); basicAttrArea = cfg.Extensions.unmarshal_compatible_list_cfg_fight_AttrAreaMinMax(os); os = _oldOs; break; }   
             case (Tag.INT | (12 << Tag.TAG_SHIFT)):   quenchingAttrNum = os.ReadInt(); break;  
             case (Tag.MAP | (13 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); affixNum = cfg.Extensions.unmarshal_compatible_map_int_int(os); os = _oldOs; break; }   
             case (Tag.BEAN | (14 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); transAffixCost = cfg.Extensions.unmarshal_compatible_cfg_condition_MultiCondition(os); os = _oldOs; break; }   
             
            default: Tag.SkipUnknownField(_id_, os); break;
            }
         }
    }
    public override void MarshalXml(XmlWriter ele)
    {
        ele.WriteAttributeString("type", "Jewelry");
        ele.WriteStartElement("id"); ele.WriteAttributeString("id", "1"); ele.WriteInt(id); ele.WriteEndElement();
         ele.WriteStartElement("name"); ele.WriteAttributeString("id", "2"); ele.WriteString2(name); ele.WriteEndElement();
         ele.WriteStartElement("jewelryType"); ele.WriteAttributeString("id", "3"); ele.WriteEnum(jewelryType); ele.WriteEndElement();
         ele.WriteStartElement("displayJewelryType"); ele.WriteAttributeString("id", "4"); ele.WriteString2(displayJewelryType); ele.WriteEndElement();
         ele.WriteStartElement("icon"); ele.WriteAttributeString("id", "5"); ele.WriteString2(icon); ele.WriteEndElement();
         ele.WriteStartElement("quality"); ele.WriteAttributeString("id", "6"); ele.WriteEnum(quality); ele.WriteEndElement();
         ele.WriteStartElement("wearCondition"); ele.WriteAttributeString("id", "7"); ele.WriteInt(wearCondition); ele.WriteEndElement();
         ele.WriteStartElement("introduction"); ele.WriteAttributeString("id", "8"); ele.WriteString2(introduction); ele.WriteEndElement();
         ele.WriteStartElement("maxPile"); ele.WriteAttributeString("id", "9"); ele.WriteInt(maxPile); ele.WriteEndElement();
         ele.WriteStartElement("durable"); ele.WriteAttributeString("id", "10"); ele.WriteInt(durable); ele.WriteEndElement();
         ele.WriteStartElement("basicAttrArea"); ele.WriteAttributeString("id", "11"); cfg.Extensions.xml_marshal_list_cfg_fight_AttrAreaMinMax(basicAttrArea,ele); ele.WriteEndElement();
         ele.WriteStartElement("quenchingAttrNum"); ele.WriteAttributeString("id", "12"); ele.WriteInt(quenchingAttrNum); ele.WriteEndElement();
         ele.WriteStartElement("affixNum"); ele.WriteAttributeString("id", "13"); cfg.Extensions.xml_marshal_map_int_int(affixNum,ele); ele.WriteEndElement();
         ele.WriteStartElement("transAffixCost"); ele.WriteAttributeString("id", "14"); cfg.Extensions.xml_marshal_cfg_condition_MultiCondition(transAffixCost,ele); ele.WriteEndElement();
         
    }

    public override void UnmarshalXml(XmlElement ele)
    {
        foreach (XmlElement e in ele.GetChildren())
        {
            if (int.TryParse(ele.GetAttribute("id"), out var _id_))
            {
                switch (_id_)
                {
                case 1:  id = ele.ReadInt(); break; 
                 case 2:  name = ele.ReadString2(); break; 
                 case 3:  jewelryType = ele.ReadEnum<cfg.jewelry.EJewelryType>(); break; 
                 case 4:  displayJewelryType = ele.ReadString2(); break; 
                 case 5:  icon = ele.ReadString2(); break; 
                 case 6:  quality = ele.ReadEnum<cfg.jewelry.EQualityColor>(); break; 
                 case 7:  wearCondition = ele.ReadInt(); break; 
                 case 8:  introduction = ele.ReadString2(); break; 
                 case 9:  maxPile = ele.ReadInt(); break; 
                 case 10:  durable = ele.ReadInt(); break; 
                 case 11:  basicAttrArea = cfg.Extensions.xml_unmarshal_list_cfg_fight_AttrAreaMinMax(ele); break; 
                 case 12:  quenchingAttrNum = ele.ReadInt(); break; 
                 case 13:  affixNum = cfg.Extensions.xml_unmarshal_map_int_int(ele); break; 
                 case 14:  transAffixCost = cfg.Extensions.xml_unmarshal_cfg_condition_MultiCondition(ele); break; 
                 
                default: break;
                }
            }
            else
            {
                switch (e.Name)
                {
                case "id":  id = ele.ReadInt(); break; 
                 case "name":  name = ele.ReadString2(); break; 
                 case "jewelry_type":  jewelryType = ele.ReadEnum<cfg.jewelry.EJewelryType>(); break; 
                 case "display_jewelry_type":  displayJewelryType = ele.ReadString2(); break; 
                 case "icon":  icon = ele.ReadString2(); break; 
                 case "quality":  quality = ele.ReadEnum<cfg.jewelry.EQualityColor>(); break; 
                 case "wear_condition":  wearCondition = ele.ReadInt(); break; 
                 case "introduction":  introduction = ele.ReadString2(); break; 
                 case "max_pile":  maxPile = ele.ReadInt(); break; 
                 case "durable":  durable = ele.ReadInt(); break; 
                 case "basic_attr_area":  basicAttrArea = cfg.Extensions.xml_unmarshal_list_cfg_fight_AttrAreaMinMax(ele); break; 
                 case "quenching_attr_num":  quenchingAttrNum = ele.ReadInt(); break; 
                 case "affix_num":  affixNum = cfg.Extensions.xml_unmarshal_map_int_int(ele); break; 
                 case "trans_affix_cost":  transAffixCost = cfg.Extensions.xml_unmarshal_cfg_condition_MultiCondition(ele); break; 
                 
                default: break;
                }
            }
        }
    }
}
}
}
